package com.market.plus.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.market.plus.core.dto.AlbumDto;
import com.market.plus.core.dto.NewsDto;
import com.market.plus.core.dto.ParticipantDto;
import com.market.plus.core.dto.TribeDto;

import com.market.plus.core.service.NewsService;
import com.market.plus.core.service.ParticipantService;
import com.market.plus.core.service.ProcessGuestService;
import com.market.plus.core.util.MarketUtil;

@Service("processGuestService")
public class ProcessGuestServiceImpl implements ProcessGuestService {

   private NewsService newsService;
   
   private ParticipantService participantService;

   @Autowired
   public ProcessGuestServiceImpl(
       @Qualifier("participantService")ParticipantService participantService,
       @Qualifier("newsService")NewsService newsService) {
      this.participantService = participantService;
      this.newsService = newsService;
   }

   public List<AlbumDto> getAlbums() {
      // TODO Auto-generated method stub
      return null;
   }

   public List<TribeDto> getTribes() {
      // TODO Auto-generated method stub
      return null;
   }

   public List<NewsDto> getNews() {
      List<NewsDto> newsDtos = null;
      ParticipantDto participantDto = MarketUtil.getCurrentView();
      ParticipantDto friend = MarketUtil.getCurrentLogin();
      newsDtos = this.newsService.filterByFriends(participantDto, new ParticipantDto[]{friend});
      return newsDtos;
   }

   public List<ParticipantDto> listFriends() {
      ParticipantDto login = MarketUtil.getCurrentLogin();
      List<Long> excludeIds = participantService.listMyLockeds(login.getId());
      excludeIds.add(login.getId());
      ParticipantDto participantDto = MarketUtil.getCurrentView();
      List<ParticipantDto> participantDtos = participantService.filterMyFriends(participantDto.getId(), excludeIds);
      return participantDtos;
   }

   public NewsDto getPersonalIntroduction() {
      ParticipantDto participantDto = MarketUtil.getCurrentView();
      NewsDto newsDto = this.newsService.getPersonalIntroduction(participantDto.getId());
      return newsDto;
   }
}
